/*testando*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

typedef struct data {
    int tam;
    char* login;
    char* mode;
    char sex;
} data;

typedef struct pIndex {
    char login[21];
    unsigned int offset;
} pIndex;

typedef struct mIndex {
    struct pIndex pmIndex[15];
    char mode[21];
} mIndex;

typedef struct sIndex {
    struct pIndex psIndex[50];
    char sex;
} sIndex;

int insertClient ()
{
    char name[21], mode[21], tmp[47], sex;
    unsigned int length;

    scanf("%s", name);
    scanf("%s", mode);
    getchar();
    scanf("%c", &sex);
    length = strlen(name) + strlen(mode) + 1 /*char of sex*/ + 3; /*delimiters*/
    if (length < 10) length += 1;
    else if (length < 100) length += 2;
    sprintf(tmp, "%d%s|%s|%c|", length, name, mode, sex);

    return 0;
}

int searchMode ()
{
    return 0;
}

int searchSex ()
{
    return 0;
}

int searchDual ()
{
    return 0;
}

int main (int argc, char** argv)
{
    FILE *data, *index, *index1, *index2;
    char cChoice[3] = "aa";

    if((data = fopen("data.dat", "a+")) == NULL) return -1;
    if((index = fopen("index.dat", "a+")) == NULL) return -1;
    if((index1 = fopen("index1.dat", "a+")) == NULL) return -1;
    if((index2 = fopen("index2.dat", "a+")) == NULL) return -1;

    pIndex *pIndex;
    sIndex *sIndex;
    mIndex *mIndex;

    scanf("%s", cChoice);

    while (strcmp(cChoice, "FM")){

        if (strcmp(cChoice, "IC")){
            insertClient(data);
            printf("ok");
        }

        if (strcmp(cChoice, "BM")){

        }

        if (strcmp(cChoice, "BS")){

        }

        if (strcmp(cChoice, "BD")){

        }

        scanf("%s", cChoice);
    }

    return 0;
}
